﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;
using DataAccessLayer.Models;

namespace PresentationLayerMVC.Controllers
{
    [HandleError]
    public class HomeController : BaseController
    {
        IAppRepository appRepo;

        public HomeController()
        {
            appRepo = new ApplicationRepository();
        }

        public ActionResult Index()
        {
            ViewData["Message"] = "Welcome to ASP.NET MVC!";

            return View();
        }

        public ActionResult About()
        {
            return View();
        }

        //
        // GET: /LOS/

        public ActionResult Home()
        {
            int userId = GetUserIdFromSession();

            IEnumerable<Application> apps = appRepo.FindAllApplication(userId);
            return View(apps);
        }

        public ActionResult Create()
        {
            return Next(Constants.ACT_CREATE_NEWAPP);
        }
    }
}
